package com.cow.framework.utils.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

public class SessionUtil {
	/**获取Request*/
	public static HttpServletRequest getRequest(){
		//获取当前会话
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return attributes.getRequest();
	}
	
	/**获取Response*/
	public static HttpServletResponse getResponse(){
		//获取当前会话
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return attributes.getResponse();
	}
	
	/**获取Session*/
	public static HttpSession getSession(){
		//获取当前会话
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return attributes.getRequest().getSession();
	}
	
	/**获取会话编号*/
	public static String getSessionId(){
		//获取当前会话
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return attributes.getSessionId();
	}
}
